class LayerModel {

    constructor() {

    }

    alert(content, title = '出错啦') {
        return new Promise(function (resolve, reject) {
            uni.showModal({
                title,
                showCancel: false,
                content,
                success: () => {
                    resolve();
                }
            })
        });
    }


    confirm(msg, title) {
        this.alert(msg);
    }


    warning(msg) {
        this.alert(msg);
    }

    error(msg) {
        this.toptip(msg, 'error');
    }

    success(msg, time = 1500) {
        return new Promise(function (resolve, reject) {
            uni.showToast({
                title: msg,
                duration: time
            });
            setTimeout(function () {
                resolve();
            }, time);
        });
    }

    toptip(msg) {
        this.alert(msg);
    }

    toast(msg, time = 1500) {
        return new Promise(function (resolve, reject) {
            uni.showToast({
                title: msg,
                duration: time
            });
            setTimeout(function () {
                resolve();
            }, time);
        });
    }

    loading(title) {

        uni.showLoading({
            title
        });
    }

    hideLoading() {

        uni.hideLoading();
    }

    notice(content, title = '温馨提示'){
        uni.showModal({
            title,
            showCancel: false,
            content
        });
    }
}


const layer = new LayerModel();

export {
    layer,
    LayerModel
}
